// select-pickup-site
import { tipToast, navBack } from '../../../common/env';

const app = getApp();
Page({
    data: {
        siteList: [],
        selectItem: null,
    },
    onLoad: function (options) {
        const { siteId } = options;
        if (siteId) {
            this.setData({
                selectItem: this.data.siteList.filter(item => item.id == siteId)[0],
            });
        }
    },
    // 选择修改
    changeSelectSite: function (event) {
        this.setData({
            selectItem: event.detail,
        });
    },
    // 确认选择
    ensureSelectPickupSite: function () {
        if (!this.data.selectItem) {
            tipToast('请先选择自提点');
            return;
        }
        // 设置数据
        app.event.trigger('changeSiteInfo', this.data.selectItem)
        // 返回上个页面
        navBack();
    },
})